/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package de.hsmannheim.pepa.patientenportal.apanwep.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import de.hsmannheim.pepa.patientenportal.apanwep.model.message;
import de.hsmannheim.pepa.patientenportal.apanwep.model.messageModel;
import de.hsmannheim.pepa.patientenportal.apanwep.model.messageSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the message service. Represents a row in the &quot;messages&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link de.hsmannheim.pepa.patientenportal.apanwep.model.messageModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link messageImpl}.
 * </p>
 *
 * @author Cedric Nana
 * @see messageImpl
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.message
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.messageModel
 * @generated
 */
@JSON(strict = true)
public class messageModelImpl extends BaseModelImpl<message>
	implements messageModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a message model instance should use the {@link de.hsmannheim.pepa.patientenportal.apanwep.model.message} interface instead.
	 */
	public static final String TABLE_NAME = "messages";
	public static final Object[][] TABLE_COLUMNS = {
			{ "id", Types.BIGINT },
			{ "eventactioncode", Types.VARCHAR },
			{ "eventdatetime", Types.VARCHAR },
			{ "eventoutcome", Types.BIGINT },
			{ "sourceaddress", Types.VARCHAR },
			{ "eventid_id", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table messages (id LONG not null primary key,eventactioncode VARCHAR(75) null,eventdatetime VARCHAR(75) null,eventoutcome LONG,sourceaddress VARCHAR(75) null,eventid_id LONG)";
	public static final String TABLE_SQL_DROP = "drop table messages";
	public static final String ORDER_BY_JPQL = " ORDER BY message.messageId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY messages.id ASC";
	public static final String DATA_SOURCE = "myDataSource";
	public static final String SESSION_FACTORY = "mySessionFactory";
	public static final String TX_MANAGER = "myTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.message"),
			false);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.message"),
			false);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static message toModel(messageSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		message model = new messageImpl();

		model.setMessageId(soapModel.getMessageId());
		model.setEventactioncode(soapModel.getEventactioncode());
		model.setEventdatetime(soapModel.getEventdatetime());
		model.setEventoutcome(soapModel.getEventoutcome());
		model.setSourceaddress(soapModel.getSourceaddress());
		model.setEventid_id(soapModel.getEventid_id());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<message> toModels(messageSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<message> models = new ArrayList<message>(soapModels.length);

		for (messageSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.de.hsmannheim.pepa.patientenportal.apanwep.model.message"));

	public messageModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _messageId;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setMessageId(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _messageId;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return message.class;
	}

	@Override
	public String getModelClassName() {
		return message.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("messageId", getMessageId());
		attributes.put("eventactioncode", getEventactioncode());
		attributes.put("eventdatetime", getEventdatetime());
		attributes.put("eventoutcome", getEventoutcome());
		attributes.put("sourceaddress", getSourceaddress());
		attributes.put("eventid_id", getEventid_id());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long messageId = (Long)attributes.get("messageId");

		if (messageId != null) {
			setMessageId(messageId);
		}

		String eventactioncode = (String)attributes.get("eventactioncode");

		if (eventactioncode != null) {
			setEventactioncode(eventactioncode);
		}

		String eventdatetime = (String)attributes.get("eventdatetime");

		if (eventdatetime != null) {
			setEventdatetime(eventdatetime);
		}

		Long eventoutcome = (Long)attributes.get("eventoutcome");

		if (eventoutcome != null) {
			setEventoutcome(eventoutcome);
		}

		String sourceaddress = (String)attributes.get("sourceaddress");

		if (sourceaddress != null) {
			setSourceaddress(sourceaddress);
		}

		Long eventid_id = (Long)attributes.get("eventid_id");

		if (eventid_id != null) {
			setEventid_id(eventid_id);
		}
	}

	@JSON
	@Override
	public long getMessageId() {
		return _messageId;
	}

	@Override
	public void setMessageId(long messageId) {
		_messageId = messageId;
	}

	@JSON
	@Override
	public String getEventactioncode() {
		if (_eventactioncode == null) {
			return StringPool.BLANK;
		}
		else {
			return _eventactioncode;
		}
	}

	@Override
	public void setEventactioncode(String eventactioncode) {
		_eventactioncode = eventactioncode;
	}

	@JSON
	@Override
	public String getEventdatetime() {
		if (_eventdatetime == null) {
			return StringPool.BLANK;
		}
		else {
			return _eventdatetime;
		}
	}

	@Override
	public void setEventdatetime(String eventdatetime) {
		_eventdatetime = eventdatetime;
	}

	@JSON
	@Override
	public long getEventoutcome() {
		return _eventoutcome;
	}

	@Override
	public void setEventoutcome(long eventoutcome) {
		_eventoutcome = eventoutcome;
	}

	@JSON
	@Override
	public String getSourceaddress() {
		if (_sourceaddress == null) {
			return StringPool.BLANK;
		}
		else {
			return _sourceaddress;
		}
	}

	@Override
	public void setSourceaddress(String sourceaddress) {
		_sourceaddress = sourceaddress;
	}

	@JSON
	@Override
	public long getEventid_id() {
		return _eventid_id;
	}

	@Override
	public void setEventid_id(long eventid_id) {
		_eventid_id = eventid_id;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			message.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public message toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (message)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		messageImpl messageImpl = new messageImpl();

		messageImpl.setMessageId(getMessageId());
		messageImpl.setEventactioncode(getEventactioncode());
		messageImpl.setEventdatetime(getEventdatetime());
		messageImpl.setEventoutcome(getEventoutcome());
		messageImpl.setSourceaddress(getSourceaddress());
		messageImpl.setEventid_id(getEventid_id());

		messageImpl.resetOriginalValues();

		return messageImpl;
	}

	@Override
	public int compareTo(message message) {
		long primaryKey = message.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof message)) {
			return false;
		}

		message message = (message)obj;

		long primaryKey = message.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<message> toCacheModel() {
		messageCacheModel messageCacheModel = new messageCacheModel();

		messageCacheModel.messageId = getMessageId();

		messageCacheModel.eventactioncode = getEventactioncode();

		String eventactioncode = messageCacheModel.eventactioncode;

		if ((eventactioncode != null) && (eventactioncode.length() == 0)) {
			messageCacheModel.eventactioncode = null;
		}

		messageCacheModel.eventdatetime = getEventdatetime();

		String eventdatetime = messageCacheModel.eventdatetime;

		if ((eventdatetime != null) && (eventdatetime.length() == 0)) {
			messageCacheModel.eventdatetime = null;
		}

		messageCacheModel.eventoutcome = getEventoutcome();

		messageCacheModel.sourceaddress = getSourceaddress();

		String sourceaddress = messageCacheModel.sourceaddress;

		if ((sourceaddress != null) && (sourceaddress.length() == 0)) {
			messageCacheModel.sourceaddress = null;
		}

		messageCacheModel.eventid_id = getEventid_id();

		return messageCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{messageId=");
		sb.append(getMessageId());
		sb.append(", eventactioncode=");
		sb.append(getEventactioncode());
		sb.append(", eventdatetime=");
		sb.append(getEventdatetime());
		sb.append(", eventoutcome=");
		sb.append(getEventoutcome());
		sb.append(", sourceaddress=");
		sb.append(getSourceaddress());
		sb.append(", eventid_id=");
		sb.append(getEventid_id());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("de.hsmannheim.pepa.patientenportal.apanwep.model.message");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>messageId</column-name><column-value><![CDATA[");
		sb.append(getMessageId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>eventactioncode</column-name><column-value><![CDATA[");
		sb.append(getEventactioncode());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>eventdatetime</column-name><column-value><![CDATA[");
		sb.append(getEventdatetime());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>eventoutcome</column-name><column-value><![CDATA[");
		sb.append(getEventoutcome());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sourceaddress</column-name><column-value><![CDATA[");
		sb.append(getSourceaddress());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>eventid_id</column-name><column-value><![CDATA[");
		sb.append(getEventid_id());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = message.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			message.class
		};
	private long _messageId;
	private String _eventactioncode;
	private String _eventdatetime;
	private long _eventoutcome;
	private String _sourceaddress;
	private long _eventid_id;
	private message _escapedModel;
}